Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming
Defining classes
Progress allows you to define a class as a named block that always begins with the
CLASSstatement and always ends with theENDCLASSstatement. TheCLASSstatement identifies the file to the compiler as a class and provides the class type name that other classes can use to inherit from it. This statement can optionally identify a super class that the class inherits from, as well as one or more interface classes that define methods that the class implements. The class can define itself asFINAL, which prevents it from being used as a super class. A class can contain essentially the same kinds of definitions for variables and other data elements as procedures. Classes are alwaysPUBLIC.The main block of a class can contain non-executable statements that define:
- Any number of data members, including ProDataSets, temp-tables, and simple variables. (See the "Defining data members" section.)
- Any number of
ONstatements, which specify Progress event handlers for widget and low-level events. (See theONstatement reference entry in OpenEdge Development: Progress 4GL Reference .)- Any number of methods. (See the "Defining methods" section.)
- Any number of user-defined function prototypes (not the functions themselves). (See the
FUNCTIONstatement reference entry in OpenEdge Development: Progress 4GL Reference .)- An optional constructor. (See the "Defining the constructor" section.)
- An optional destructor. (See the "Defining the destructor" section.)
The main block of a class cannot contain any executable statements that are outside of a method, constructor, destructor, or
ONstatement definition. For more information on defining classes, see the "Defining a class" section.Comparison with procedure-based programming
A persistent procedure can contain executable statements in its main block and can define parameters. Classes provide a constructor to provide the same functionality. The equivalent of data members for persistent procedures are variables and other data elements defined in the main block. The equivalent of methods for persistent procedures are internal procedures and user-defined functions.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |